import $ from 'jquery';
//这个写法是只读的
//import BpmnModeler from 'bpmn-js';
//这个写法是可编辑的
import BpmnModeler from 'bpmn-js/lib/Modeler';
import testDiagram from '../resources/newDiagram.bpmn';
import propertiesPanelModule from 'bpmn-js-properties-panel';
//import propertiesProviderModule from 'bpmn-js-properties-panel/lib/provider/camunda';
import propertiesProviderModule from '../resources/properties-panel/provider/activiti';
import activitiModdleDescriptor from '../resources/activiti.json';
import customTranslate from '../resources/customTranslate/customTranslate';
import customControlsModule from '../resources/customControls';


const proHost = window.location.protocol + "//" + window.location.host;
const href = window.location.href.split("bpmnjs")[0];
const key = href.split(window.location.host)[1];
const publicurl = proHost + key;
var modelId = "";

var container = $('#js-drop-zone');
var canvas = $('#js-canvas');

//container.removeClass('with-diagram');

var customTranslateModule = {
  translate: ['value', customTranslate]
};
var viewer = new BpmnModeler({
  container: '#js-canvas',
	//添加控制板
	propertiesPanel: {
		parent: '#js-properties-panel'
	},
	additionalModules: [
		propertiesPanelModule,
		// 左边工具栏以及节点
		propertiesProviderModule,
		customControlsModule,
		customTranslateModule
	],
	moddleExtensions: {
		activiti:activitiModdleDescriptor
	}
});




viewer.importXML(testDiagram, function(err) {
  if (!err) {
    console.log('success!');
    viewer.get('canvas').zoom('fit-viewport');
  } else {
    console.log('something went wrong:', err);
  }
});

